userâs mailbox size report in exchange 2003
Hi All
I have exchange 2003.
I need to get the users mailbox size report according to OU. I have separated the users in different OU.
regards,
avinash
September 30th, 2010 2:36am
Hope below WMI script will help you to achive this, But you may have to do some tweak in below commands
#use WMI to get all mailboxes from each exchange 2003 server and put into array
#will only get mailboxes that are not disconnected. This WMI Property is "datediscoveredabsentinDS"
"Retriving all mailboxes........"
$allmailboxes = Get-WMIObject -namespace root\MicrosoftExchangeV2 -class Exchange_Mailbox -computer servername | where {$_.datediscoveredabsentinds -eq $NULL}
"Done retrieviing mailboxes....."
$allmailboxes.count
#Create Excel spreadsheet to write output to
"creating Excel spreadsheet....."
#Open Excel and add a worksheet
$excel = New-Object -ComObject Excel.Application
$excel.visible = $True
$workbook = $excel.Workbooks.add()
$sheet = $workbook.worksheets.Item(1)
#Write column headers to spreadsheet
$sheet.cells.item(1,1) = "Name from WMI"
$sheet.cells.item(1,2) = "Office"
$sheet.cells.item(1,3) = "Size"
$sheet.cells.item(1,4) = "Server"
$sheet.cells.item(1,5) = "Storage Group"
$sheet.cells.item(1,6) = "Store"
$sheet.cells.item(1,7) = "Display from LDAP"
$sheet.cells.item(1,8) = "legacydn"
#set variable "X" to 2 so data starts writing to second row
$x = 2
"Entering Loop to get AD information for each mailbox and output...."
foreach ($mailbox in $allmailboxes)
{
#Make connection to AD
$Filter = "(&(objectClass=user)(objectCategory=person)(legacyExchangeDN=$($mailbox.legacydn)))"
$Searcher = New-Object System.DirectoryServices.DirectorySearcher($Null, $Filter)
# These are the fields returned by the DirectorySearcher
$Searcher.PropertiesToLoad.AddRange(@("name", "legacyExchangeDN", "displayname", `
"physicalDeliveryOfficeName", "mail", "samaccountname"))
# Because legacyDN is a unique attribute we can use FindOne instead of FindAll
$ldapmbx = $Searcher.FindOne()
[string]$displayname = $ldapmbx.properties.displayname
$size = $mailbox.size
[string]$office = $ldapmbx.properties.physicaldeliveryofficename
$server = $mailbox.servername
$storagegroup = $mailbox.storagegroupname
$store = $mailbox.storename
$mailboxdisplayname = $mailbox.mailboxdisplayname
$legacy = $mailbox.legacydn
#write variables into new row on spreadsheet
$sheet.cells.item($x,1) = $mailboxdisplayname
$sheet.cells.item($x,2) = $office
$sheet.cells.item($x,3) = $size
$sheet.cells.item($x,4) = $server
$sheet.cells.item($x,5) = $storagegroup
$sheet.cells.item($x,6) = $store
$sheet.cells.item($x,7) = $displayname
$sheet.cells.item($x,8) = $legacy
#"$displayname" + " " + "Size = $size" + " " + "$office" + " " + "$server" + " " + "$storagegroup" + " " + "$store"
#clear variables
$displayname = "nomatch"
$size = 0
$office = "nomatch"
$server = "nomatch"
$storagegroup = "nomatch"
$store = "nomatch"
$mailboxdisplayname = "nomatch"
$legacy = ""
#increment $X so that next time in loop writes to next row
$x ++
# Clear the searcher
$Searcher = $Null
}
---------------Anil
Free Windows Admin Tool Kit Click here and download it now
September 30th, 2010 3:48am
I ran the script however it will only return Exchange 2003 propertie not the active directory propertie set
March 22nd, 2011 4:32pm